﻿@model IEnumerable<CSF.Customers.Data.Customer>
@{
    ViewBag.Title = "Index";
    ViewBag.SubTitle = "Customer";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="applicationPanel" class="easyui-panel" title="Grid" icon="icon-save" collapsible="true"
    style="width: auto; padding: 10px; background: #fafafa;">
    @using (Html.BeginForm("Index", "Customer", FormMethod.Get))
    { 
        @Html.Hidden("SessionId", Request["SessionId"])
        <div style="text-align: right">
            &nbsp;&nbsp;Code:<input id="Code" name="Code" />
            Name:<input id="Name1" name="Name1" />
            <a href="javascript:submitSearch();" class="easyui-linkbutton" iconcls="icon-search"
                plain="true">Search</a>
            <input id="search" type="submit" value="submit" style="display: none" />
        </div>
       
    }
    @using (Html.BeginForm("Delete", "Customer"))
    {
        @Html.Hidden("toUrl", Request.Url.ToString())
        <div id="toolbar" style="width: 90%">
            &nbsp;&nbsp;<input type="checkbox" id="chkAll" name="chkAll" />Select All&nbsp;&nbsp;
            <a href="@Url.Action("Add", "Customer")" class="easyui-linkbutton" iconcls="icon-add" plain="true">
                Add</a> &nbsp;&nbsp; <a href="javascript:submitToggleActive();" class="easyui-linkbutton"
                    iconcls="icon-no" plain="true">Delete</a>
        </div>
        <div id="grid">
            @{  var grid = new WebGrid(source: Model, defaultSort: "Code", rowsPerPage: 12, ajaxUpdateContainerId: "grid");    
                @grid.GetHtml(
                               tableStyle: "webGrid",
                               headerStyle: "header",
                               alternatingRowStyle: "alt",
                                footerStyle: "foot",
                                columns: grid.Columns(
                                grid.Column(format: (item) => Html.CheckBox("Id", "Id"), header: ""),
                                                        grid.Column("Code", "Code"),
            //grid.Column("ParentId", "ParentId"),
            //grid.Column("CustomerTypeId", "CustomerTypeId"),
                                                        grid.Column("NickName", "Nick Name"),
                                                        grid.Column("FullName", "Full Name"),
                                                        grid.Column("Address1", "Address1"),
            //grid.Column("Address2", "Address2"),
            //grid.Column("City", "City"),
            //grid.Column("CountryCode", "CountryCode"),
            //grid.Column("CreditClassCode", "CreditClassCode"),
                                                        grid.Column("Email", "Email"),
            //grid.Column("Fax", "Fax"),
            //grid.Column("Mobile", "Mobile"),
            //grid.Column("Phone", "Phone"),
            //grid.Column("Province", "Province"),
            //grid.Column("Suburb", "Suburb"),
                                                        grid.Column("ZipCode", "Zip Code"),
            //grid.Column("InMailList", "InMailList"),
            //grid.Column("CourierAccountNo", "CourierAccountNo"),
                                                        grid.Column("VatNo", "Vat No."),
            //grid.Column("RegionCode", "RegionCode"),
            //grid.Column("WebSite", "WebSite"),
            //grid.Column("Logo", "Logo"),
            //grid.Column("Remarks", "Remarks"),
            //grid.Column("ApproveBy", "ApproveBy"),
            //grid.Column("ApproveTime", "ApproveTime"),
            //grid.Column("IsDisable", "IsDisable"),
             grid.Column(format: (item) => Html.ActionLink("Loft", "SubCustomer", new { ParentId = item.Id })),
          grid.Column(format: (item) => Html.ActionLink("View User", "Index", "CustomerUserAccount", new { cid = item.Id }, null)),
             grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.Id })),
             grid.Column(format: (item) => Html.ActionLink("Delete", "Delete", new { id = item.Id, toUrl = Request.Url.ToString() }))

                                                   ),
                                     fillEmptyRows: !IsPost,
                                     mode: WebGridPagerModes.All,
                                     firstText: "First Page",
                                     previousText: "Previous Page",
                                     nextText: "Next Page",
                                     lastText: "Last Page",
                                     numericLinksCount: 15

                               ) 
            }
        </div>
        <br />
        <input id="submit" type="submit" value="submit" style="display: none" />    
    }
</div>
<script type="text/javascript">
    $('#chkAll').click(function () {
        $(':checkbox[name="Id"]').attr('checked', $(this).attr('checked'));
    });
    function submitToggleActive() {
        $('#submit').click();
    }
    function submitSearch() {
        $('#search').click();
    }
</script>
